<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active {
            color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- 数组语法 知道就可以了 -->
        <h2 :class="[active]">{{nam}}</h2>
        <button @click="ann">按钮</button>
    </div>
    <script src="../../node_modules/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                nam: 'ling',
                isActive: true,

            },
            methods: {
                ann: function() {
                    this.isActive = !this.isActive;
                }
            }
        })
    </script>
</body>

</html>